home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / sendmail / ease-3.5 / debug / showhow < prev    next >
Encoding:
Text File  |  1991-02-26  |  1.2 KB  |  57 lines

  1. #!/bin/sh  
  2. # written by Bruce Barnett <barnett@crdgw1.ge.com>
  3. # Inspired from
  4. #    Dan Long
  5. #     CSNET Technical Staff
  6. #     long@sh.cs.net
  7. #
  8. #    This script converts the sendmail debug output into something 
  9. #    easier to parse.
  10. #    Some sendmail programs output ^V, ^W, ^X
  11. #    This script converts ^V to $#, ^X to $:, and ^W to $@
  12. #    This matches Ultrix 3.1. SunOS 3.5 is different
  13. #    Other sendmail versions output in the $:, $@, $# format
  14. #    So this script just ignores those characters, 
  15. #    as they are already correct.
  16. #
  17. #define your sendmail program compiled for debug
  18. SENDMAIL=/usr/lib/sendmail
  19. if [ $# -lt 2 ]
  20. then
  21.     echo 'Usage: showhow rulesets address [mailer]' 1>&2;exit 2;
  22. fi
  23. #FLAGS='-d21.12'
  24. FLAGS=''
  25. case $1 in
  26. 0*)
  27.     echo "$1 $2" | ${SENDMAIL} -bt -Csendmail.cf $FLAGS  |\
  28.     egrep '\$\#|\^V' |\
  29.     tail -1 |tr -d '"' |\
  30.     sed \
  31.         -e 's/\^V/$#/' \
  32.         -e 's/\^X/$:/' \
  33.         -e 's/\^W/$@/' \
  34.         -e 's/^[a-zA-Z ][:a-zA-Z0-9 ]*//' \
  35.         -e 's/local \$:/local $@ local $:/' \
  36.         -e 's/\$# //' \
  37.         -e 's/ \$@ /    /' \
  38.         -e 's/ \$: /    /' \
  39.         -e 's/ //g' 
  40.     ;;
  41. *)    # else a rewrite rule for a mailer
  42.     if [ X$3 = X ]
  43.     then
  44.         mailer='-';
  45.     else
  46.         mailer=$3;
  47.     fi
  48.     echo "$1 $2" | ${SENDMAIL} -bt -Csendmail.cf $FLAGS |\
  49.     egrep "^rewrite:"|tail -1 |tr -d '" '|\
  50.     sed "s/^.*:/$mailer    /"
  51.     ;;
  52. esac
  53.  
  54.  
  55.  
  56.  
  57.